// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.inventory.types;

import java.util.Arrays;
import java.util.List;
import zombie.characters.IsoGameCharacter;
import zombie.inventory.InventoryItem;

public enum WeaponType {
    barehand("", Arrays.asList(""), true, false),
    twohanded("2handed", Arrays.asList("default", "default", "overhead", "uppercut"), true, false),
    onehanded("1handed", Arrays.asList("default", "default", "overhead", "uppercut"), true, false),
    heavy("heavy", Arrays.asList("default", "default", "overhead"), true, false),
    knife("knife", Arrays.asList("default", "default", "overhead", "uppercut"), true, false),
    spear("spear", Arrays.asList("default"), true, false),
    handgun("handgun", Arrays.asList(""), false, true),
    firearm("firearm", Arrays.asList(""), false, true),
    throwing("throwing", Arrays.asList(""), false, true),
    chainsaw("chainsaw", Arrays.asList("default"), true, false);

    public String type = "";
    public List<String> possibleAttack;
    public boolean canMiss = true;
    public boolean isRanged = false;

    private WeaponType(String string1, List<String> list, boolean boolean0, boolean boolean1) {
        this.type = string1;
        this.possibleAttack = list;
        this.canMiss = boolean0;
        this.isRanged = boolean1;
    }

    public static WeaponType getWeaponType(HandWeapon weapon) {
        WeaponType weaponType = null;
        if (weapon.getSwingAnim().equalsIgnoreCase("Stab")) {
            return knife;
        } else if (weapon.getSwingAnim().equalsIgnoreCase("Heavy")) {
            return heavy;
        } else if (weapon.getSwingAnim().equalsIgnoreCase("Throw")) {
            return throwing;
        } else {
            if (!weapon.isRanged()) {
                weaponType = onehanded;
                if (weapon.isTwoHandWeapon()) {
                    weaponType = twohanded;
                    if (weapon.getSwingAnim().equalsIgnoreCase("Spear")) {
                        return spear;
                    }

                    if ("Chainsaw".equals(weapon.getType())) {
                        return chainsaw;
                    }
                }
            } else {
                weaponType = handgun;
                if (weapon.isTwoHandWeapon()) {
                    weaponType = firearm;
                }
            }

            if (weaponType == null) {
                weaponType = barehand;
            }

            return weaponType;
        }
    }

    public static WeaponType getWeaponType(IsoGameCharacter chr) {
        if (chr == null) {
            return null;
        } else {
            WeaponType weaponType = null;
            chr.setVariable("rangedWeapon", false);
            InventoryItem inventoryItem0 = chr.getPrimaryHandItem();
            InventoryItem inventoryItem1 = chr.getSecondaryHandItem();
            if (inventoryItem0 != null && inventoryItem0 instanceof HandWeapon) {
                if (inventoryItem0.getSwingAnim().equalsIgnoreCase("Stab")) {
                    return knife;
                }

                if (inventoryItem0.getSwingAnim().equalsIgnoreCase("Heavy")) {
                    return heavy;
                }

                if (inventoryItem0.getSwingAnim().equalsIgnoreCase("Throw")) {
                    chr.setVariable("rangedWeapon", true);
                    return throwing;
                }

                if (!((HandWeapon)inventoryItem0).isRanged()) {
                    weaponType = onehanded;
                    if (inventoryItem0 == inventoryItem1 && inventoryItem0.isTwoHandWeapon()) {
                        weaponType = twohanded;
                        if (inventoryItem0.getSwingAnim().equalsIgnoreCase("Spear")) {
                            return spear;
                        }

                        if ("Chainsaw".equals(inventoryItem0.getType())) {
                            return chainsaw;
                        }
                    }
                } else {
                    weaponType = handgun;
                    if (inventoryItem0 == inventoryItem1 && inventoryItem0.isTwoHandWeapon()) {
                        weaponType = firearm;
                    }
                }
            }

            if (weaponType == null) {
                weaponType = barehand;
            }

            chr.setVariable("rangedWeapon", weaponType == handgun || weaponType == firearm);
            return weaponType;
        }
    }

    public String getType() {
        return this.type;
    }
}
